package com.gjd.controller;

import com.gjd.domain.ResponseResult;
import com.gjd.domain.entity.User;
import com.gjd.service.AdminService;
import com.gjd.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/admin/manage")
public class ManageUsersController {

    @Autowired
    private UserService userService;

    @Autowired
    private AdminService adminService;

    @GetMapping("/userListPage")
    public ResponseResult userListPage(Long pageNum, Long pageSize) {
        return userService.getUserListPage(pageNum, pageSize);
    }

    @GetMapping("/selectUserListPage")
    public ResponseResult selectUserListPage(User user, Long pageNum, Long pageSize) {
        return userService.selectUserListPage(user, pageNum, pageSize);
    }

    @GetMapping("/userInfo")
    public ResponseResult getUserInfo() {
        return userService.getuserInfo();
    }

    @PutMapping("/updateUserInfo")
    public ResponseResult updateUserInfo(@RequestBody User user) {
        return adminService.updateUserInfo(user);
    }

    @DeleteMapping("/deleteUser")
    public ResponseResult deleteUser(Long userId) {
        return userService.deleteUser(userId);
    }
}
